package org.momo.rpc.protocol.constant;

public enum MessageType {
    REQUEST(0),

    RESPONSE(1),

    HEARTBEAT_PING(2),

    HEARTBEAT_PONG(3);

    private byte code;

    MessageType(int i) {
        this.code = (byte) this.ordinal();
    }

    public static MessageType getMessageTypeEnumByCode(byte code) {
        for(MessageType messageType : values()) {
            if(messageType.code == code) {
                return messageType;
            }
        }
        return null;
    }

    public byte getCode() {
        return code;
    }
}
